#include "ExampleProcessorConfigPanel.h"

ExampleProcessorConfigPanel::ExampleProcessorConfigPanel(ExampleProcessorController * ctrl)
{
    Controller = ctrl;
}

void ExampleProcessorConfigPanel::populatePanel(QFrame *panel)
{
    RedScaling = new QSlider(Qt::Horizontal);
    RedScaling->setMaximum(100);
    RedScaling->setMinimum(0);
    RedScaling->setSingleStep(10);
    RedScaling->setValue(100);

    GreenScaling = new QSlider(Qt::Horizontal);
    GreenScaling->setMaximum(100);
    GreenScaling->setMinimum(0);
    GreenScaling->setSingleStep(10);
    GreenScaling->setValue(100);

    BlueScaling = new QSlider(Qt::Horizontal);
    BlueScaling->setMaximum(100);
    BlueScaling->setMinimum(0);
    BlueScaling->setSingleStep(10);
    BlueScaling->setValue(100);


    PanelLayout = new QGridLayout(panel);

    PanelLayout->addWidget(new QLabel("Red scaling"), 1, 1);
    PanelLayout->addWidget(RedScaling, 1, 2);

    PanelLayout->addWidget(new QLabel("Green scaling"), 3, 1);
    PanelLayout->addWidget(GreenScaling, 3, 2);

    PanelLayout->addWidget(new QLabel("Blue scaling"), 2, 1);
    PanelLayout->addWidget(BlueScaling, 2, 2);

    connectController();
}

void ExampleProcessorConfigPanel::connectController()
{

    RedScaling->connect(RedScaling, SIGNAL(valueChanged(int)), Controller, SLOT(updateRedScaling(int)));
    GreenScaling->connect(GreenScaling, SIGNAL(valueChanged(int)), Controller, SLOT(updateGreenScaling(int)));
    BlueScaling->connect(BlueScaling, SIGNAL(valueChanged(int)), Controller, SLOT(updateBlueScaling(int)));
}

ExampleProcessorConfigPanel::~ExampleProcessorConfigPanel() {
    delete RedScaling;
    delete GreenScaling;
    delete BlueScaling;
    delete PanelLayout;
}
